﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using WorkRecorder.Business;
using System.Collections.ObjectModel;
using System.Windows.Controls;

namespace WorkRecorder.Helpers.Converters
{
    public class ListboxRowNumConverter : IValueConverter
    {
        private int counter = 0;

        private ObservableCollection<Record> tempCol = null;

        public ListboxRowNumConverter() { }

        public  int GetRowNumber(object collection)
        {

            return 0;
        }

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var item = value as ListViewItem;
            //if (this.counter >= collection.Items.Count)
            //{
            //    this.counter = 0;
            //}

            ListView listView = ItemsControl.ItemsControlFromItemContainer(item) as ListView;
            int index = listView.ItemContainerGenerator.IndexFromContainer(item);
            return index;

  
 
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
